﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes.hive;

namespace SharpSqlAnalyzer.nodes
{
	// Token: 0x02000317 RID: 791
	public class TNodeFactory
	{
		// Token: 0x17000670 RID: 1648
		// (set) Token: 0x06001C0A RID: 7178 RVA: 0x003303AB File Offset: 0x0032E5AB
		public virtual TGSharpSqlParser GSharpSqlParser
		{
			set
			{
				this.gSharpSqlParser = value;
			}
		}

		// Token: 0x06001C0B RID: 7179 RVA: 0x003303B4 File Offset: 0x0032E5B4
		public virtual TColumnReference createColumnReference(TObjectName objectname)
		{
			return (TColumnReference)this.createNode(ENodeType.T_ColumnReference.Id, objectname);
		}

		// Token: 0x06001C0C RID: 7180 RVA: 0x003303CC File Offset: 0x0032E5CC
		public virtual TColumnReference createColumnReference(TSourceToken objectname)
		{
			return (TColumnReference)this.createNode(ENodeType.T_ColumnReference.Id, objectname);
		}

		// Token: 0x06001C0D RID: 7181 RVA: 0x003303E4 File Offset: 0x0032E5E4
		public virtual TTableReference createTableReference(TObjectName objectname)
		{
			return (TTableReference)this.createNode(ENodeType.T_TableReference.Id, objectname);
		}

		// Token: 0x06001C0E RID: 7182 RVA: 0x003303FC File Offset: 0x0032E5FC
		public virtual TObjectReference createObjectReference(TObjectName objectname, int objecttype)
		{
			TObjectReference tobjectReference = (TObjectReference)this.createNode(ENodeType.T_ObjectReference.Id, objectname);
			tobjectReference.ObjectType = objecttype;
			return tobjectReference;
		}

		// Token: 0x06001C0F RID: 7183 RVA: 0x0033041B File Offset: 0x0032E61B
		public virtual TParseTreeNode createIntervalExpression()
		{
			return (TIntervalExpression)this.createNode(ENodeType.T_IntervalExression.Id);
		}

		// Token: 0x06001C10 RID: 7184 RVA: 0x00330432 File Offset: 0x0032E632
		public virtual TParseTreeNode createDatetimeExpression()
		{
			return (TDatetimeExpression)this.createNode(ENodeType.T_DatetimeExression.Id);
		}

		// Token: 0x06001C11 RID: 7185 RVA: 0x00330449 File Offset: 0x0032E649
		public virtual TParseTreeNode createFunctionCall(EFunctionType eFunctionType, TObjectName functionName)
		{
			return (TFunctionCall)this.createNode(ENodeType.T_FunctionCall.Id, eFunctionType, functionName);
		}

		// Token: 0x06001C12 RID: 7186 RVA: 0x00330467 File Offset: 0x0032E667
		public virtual TParseTreeNode createSelectSqlNode()
		{
			return (TSelectSqlNode)this.createNode(ENodeType.T_SelectSqlNode.Id);
		}

		// Token: 0x06001C13 RID: 7187 RVA: 0x0033047E File Offset: 0x0032E67E
		public virtual TParseTreeNode createExpression(EExpressionType operatorType)
		{
			return (TExpression)this.createNode(ENodeType.T_Expression.Id, operatorType);
		}

		// Token: 0x06001C14 RID: 7188 RVA: 0x0033049B File Offset: 0x0032E69B
		public virtual TParseTreeNode createExpression(EExpressionType operatorType, TExpression leftOperand, TExpression rightOperand)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, operatorType);
			texpression.LeftOperand = leftOperand;
			texpression.RightOperand = rightOperand;
			return texpression;
		}

		// Token: 0x06001C15 RID: 7189 RVA: 0x003304C6 File Offset: 0x0032E6C6
		public virtual TParseTreeNode createCompoundExpression(EExpressionType operatorType, TExpression leftOperand, TExpression rightOperand)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, operatorType);
			texpression.LeftOperand = leftOperand;
			texpression.RightOperand = rightOperand;
			return texpression;
		}

		// Token: 0x06001C16 RID: 7190 RVA: 0x003304F1 File Offset: 0x0032E6F1
		public virtual TExpression createSimpleExpression(TObjectName or)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, EExpressionType.simple_object_name_t);
			texpression.ObjectOperand = or;
			texpression.startToken = or.startToken;
			texpression.endToken = or.endToken;
			return texpression;
		}

		// Token: 0x06001C17 RID: 7191 RVA: 0x00330530 File Offset: 0x0032E730
		public virtual TObjectName createObjectName(TSourceToken schema, TSourceToken @object, TSourceToken part)
		{
			if (schema == null && @object == null && part == null)
			{
				return null;
			}
			TObjectName tobjectName = (TObjectName)this.createNode(ENodeType.T_ObjectName.Id, schema, @object, part);
			if (part != null)
			{
				tobjectName.endToken = part;
			}
			else if (@object != null)
			{
				tobjectName.endToken = @object;
			}
			else if (schema != null)
			{
				tobjectName.endToken = schema;
			}
			if (schema != null)
			{
				tobjectName.startToken = schema;
			}
			else if (@object != null)
			{
				tobjectName.startToken = @object;
			}
			else if (part != null)
			{
				tobjectName.startToken = part;
			}
			return tobjectName;
		}

		// Token: 0x06001C18 RID: 7192 RVA: 0x003305A6 File Offset: 0x0032E7A6
		public virtual TObjectName createObjectNameWithPart(TSourceToken part)
		{
			return this.createObjectName(null, null, part);
		}

		// Token: 0x06001C19 RID: 7193 RVA: 0x003305B1 File Offset: 0x0032E7B1
		public virtual TObjectName createObjectNameWithObject(TSourceToken @object)
		{
			return this.createObjectName(null, @object, null);
		}

		// Token: 0x06001C1A RID: 7194 RVA: 0x003305BC File Offset: 0x0032E7BC
		public virtual TObjectName createObjectNameWithPartAndObject(TSourceToken @object, TSourceToken part)
		{
			return this.createObjectName(null, @object, part);
		}

		// Token: 0x06001C1B RID: 7195 RVA: 0x003305C7 File Offset: 0x0032E7C7
		public virtual TParseTreeNode createSimpleExpression(TConstant cnt)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, EExpressionType.simple_constant_t);
			texpression.ConstantOperand = cnt;
			texpression.startToken = cnt.startToken;
			texpression.endToken = cnt.endToken;
			return texpression;
		}

		// Token: 0x06001C1C RID: 7196 RVA: 0x00330603 File Offset: 0x0032E803
		public virtual TParseTreeNode createSimpleExpression(TSourceToken st)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, EExpressionType.simple_source_token_t);
			texpression.SourcetokenOperand = st;
			texpression.startToken = st;
			texpression.endToken = st;
			return texpression;
		}

		// Token: 0x06001C1D RID: 7197 RVA: 0x00330635 File Offset: 0x0032E835
		public virtual TParseTreeNode createSimpleExpression(THiveVariable variable)
		{
			TExpression texpression = (TExpression)this.createNode(ENodeType.T_Expression.Id, EExpressionType.hive_variable_t);
			texpression.Hive_variable = variable;
			texpression.startToken = variable.startToken;
			texpression.endToken = variable.endToken;
			return texpression;
		}

		// Token: 0x06001C1E RID: 7198 RVA: 0x00330674 File Offset: 0x0032E874
		private ELiteralType getETByNT(ENodeType ent)
		{
			ELiteralType result = ELiteralType.character_string;
			switch (ent.InnerEnumValue())
			{
			case ENodeType.InnerEnum.T_Constant_Integer:
			case ENodeType.InnerEnum.T_Constant_Float:
			case ENodeType.InnerEnum.T_Constant_Double:
				result = ELiteralType.numeric_et;
				break;
			case ENodeType.InnerEnum.T_Constant_String:
				result = ELiteralType.character_string;
				break;
			case ENodeType.InnerEnum.T_Constant_Date:
				result = ELiteralType.datetime_date;
				break;
			case ENodeType.InnerEnum.T_Constant_Timestamp:
				result = ELiteralType.datetime_timestamp;
				break;
			case ENodeType.InnerEnum.T_Constant_Time:
				result = ELiteralType.datetime_time;
				break;
			case ENodeType.InnerEnum.T_Constant_Boolean:
				result = ELiteralType.@bool;
				break;
			case ENodeType.InnerEnum.T_Constant_Interval:
				result = ELiteralType.interval;
				break;
			case ENodeType.InnerEnum.T_Constant_Null:
				result = ELiteralType.character_string;
				break;
			}
			return result;
		}

		// Token: 0x06001C1F RID: 7199 RVA: 0x003306EA File Offset: 0x0032E8EA
		public virtual TParseTreeNode createConstant(TSourceToken st, ENodeType ent)
		{
			TConstant tconstant = (TConstant)this.createNode(ENodeType.T_Constant.Id, this.getETByNT(ent));
			tconstant.startToken = st;
			tconstant.endToken = st;
			tconstant.setvalueToken(st);
			return tconstant;
		}

		// Token: 0x06001C20 RID: 7200 RVA: 0x00330722 File Offset: 0x0032E922
		public virtual TParseTreeNode createConstant(TParseTreeNode node, ENodeType ent)
		{
			TConstant tconstant = (TConstant)this.createNode(ENodeType.T_Constant.Id, this.getETByNT(ent));
			tconstant.startToken = node.startToken;
			tconstant.endToken = node.endToken;
			return tconstant;
		}

		// Token: 0x06001C21 RID: 7201 RVA: 0x00330760 File Offset: 0x0032E960
		public virtual TParseTreeNode createConstant<T>(List<T> pList, ENodeType ent)
		{
            if (pList == null)
            {
                return null;
            }
            object obj = pList[0];
            object obj2 = pList[pList.Count - 1];
            TParseTreeNode tParseTreeNode = (TParseTreeNode)obj;
            TParseTreeNode tParseTreeNode2 = (TParseTreeNode)obj2;
            TConstant obj3 = (TConstant)createNode(ENodeType.T_Constant.Id, getETByNT(ent));
            obj3.startToken = tParseTreeNode.startToken;
            obj3.endToken = tParseTreeNode2.endToken;
            return obj3;
        }

		// Token: 0x06001C22 RID: 7202 RVA: 0x003307D8 File Offset: 0x0032E9D8
		public virtual TParseTreeNode createNode(int nodeType)
		{
			Type type = null;
			TParseTreeNode tparseTreeNode = null;
			string text = this.nodeName(nodeType);
			try
			{
				type = Type.GetType(text);
			}
			catch (TypeLoadException ex)
			{
				Console.WriteLine(ex.ToString() + ", nodename: " + text);
			}
			try
			{
				tparseTreeNode = (TParseTreeNode)Activator.CreateInstance(type);
			}
			catch (Exception ex2)
			{
				Console.WriteLine(ex2.ToString() + ", nodeType: " + nodeType.ToString());
			}
			tparseTreeNode.NodeType = nodeType;
			tparseTreeNode.GSharpSqlParser = this.gSharpSqlParser;
			return tparseTreeNode;
		}

		// Token: 0x06001C23 RID: 7203 RVA: 0x00330870 File Offset: 0x0032EA70
		public virtual TPTNodeList<T> createPTNodeList<T>(T c)
		{
			int id = ENodeType.T_PTNodeList.Id;
			TPTNodeList<T> tptnodeList = new TPTNodeList<T>();
			tptnodeList.NodeType = id;
			tptnodeList.GSharpSqlParser = this.gSharpSqlParser;
			tptnodeList.init(c);
			return tptnodeList;
		}

		// Token: 0x06001C24 RID: 7204 RVA: 0x003308AC File Offset: 0x0032EAAC
		public virtual List<TParseTreeNode> createList<TParseTreeNode>(TParseTreeNode c)
		{
			return new List<TParseTreeNode>
			{
				c
			};
		}

		// Token: 0x06001C25 RID: 7205 RVA: 0x003308BA File Offset: 0x0032EABA
		protected internal virtual string nodeName(int nodeType)
		{
			return ENodeType.fromId(nodeType).ToString();
		}

		// Token: 0x06001C26 RID: 7206 RVA: 0x003308C7 File Offset: 0x0032EAC7
		public TParseTreeNode createNode(int nodeType, object arg1)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1);
			return tparseTreeNode;
		}

		// Token: 0x06001C27 RID: 7207 RVA: 0x003308D7 File Offset: 0x0032EAD7
		public TParseTreeNode createNode(int nodeType, object arg1, object arg2)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1, arg2);
			return tparseTreeNode;
		}

		// Token: 0x06001C28 RID: 7208 RVA: 0x003308E8 File Offset: 0x0032EAE8
		public TParseTreeNode createNode(int nodeType, object arg1, object arg2, object arg3)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1, arg2, arg3);
			return tparseTreeNode;
		}

		// Token: 0x06001C29 RID: 7209 RVA: 0x003308FB File Offset: 0x0032EAFB
		public TParseTreeNode createNode(int nodeType, object arg1, object arg2, object arg3, object arg4)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1, arg2, arg3, arg4);
			return tparseTreeNode;
		}

		// Token: 0x06001C2A RID: 7210 RVA: 0x00330910 File Offset: 0x0032EB10
		public TParseTreeNode createNode(int nodeType, object arg1, object arg2, object arg3, object arg4, object arg5)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1, arg2, arg3, arg4, arg5);
			return tparseTreeNode;
		}

		// Token: 0x06001C2B RID: 7211 RVA: 0x00330927 File Offset: 0x0032EB27
		public TParseTreeNode createNode(int nodeType, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
		{
			TParseTreeNode tparseTreeNode = this.createNode(nodeType);
			tparseTreeNode.init(arg1, arg2, arg3, arg4, arg5, arg6);
			return tparseTreeNode;
		}

		// Token: 0x04001A2A RID: 6698
		private TGSharpSqlParser gSharpSqlParser;
	}
}
